package cn.itsource.basic.dto;

import cn.itsource.basic.util.MD5Utils;
import cn.itsource.basic.util.StrUtils;
import cn.itsource.user.domain.User;
import lombok.Data;

import java.util.Date;


@Data
public class PhoneRegisterDto {

    private String phone;

    // uuid
    private String imageCodeKey;

    // 图形验证码
    private String imageCodeValue;

    // 手机号验证码
    private String phoneCode;

    // 密码
    private String password;
    // 确认密码
    private String passwordRepeat;

    //类型
    private String type;


    public User getUser(){
        //盐值
        String salt = StrUtils.getComplexRandomString(32);
        /// todo 盐值 + 密码
        String pw = MD5Utils.encrypByMd5(salt + this.password);
        return User
                .builder()
                .createtime(new Date())
                .salt(salt)
                .password(pw)
                .state(1)
                .phone(this.phone)
                .username(this.phone)
                .build();
    }

}
